import request from '@/utils/request'
const UpmsCategoryDictService = {
  state: {},

  mutations: {},

  actions: {
    /**
     * 分类字典树形表格
     */
    upmsCategoryDictTreeByType({ commit }, type) {
      return new Promise((resolve, reject) => {
        request.get('upmsCategoryDict/treeByType', { type: type }).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    upmsCategoryDictListByTypeAndPid({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.get('upmsCategoryDict/listByTypeAndPid', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
    * 根据主键获得分类字典
    */
    upmsCategoryDictGetById({ commit }, id) {
      return new Promise((resolve, reject) => {
        request.get('upmsCategoryDict/getById/' + id).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
    * 根据主键获得分类字典详情
    */
    upmsCategoryDictGetDetailsById({ commit }, id) {
      return new Promise((resolve, reject) => {
        request.get('upmsCategoryDict/getDetailsById/' + id).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    /**
     * 分类字典保存
     */
    upmsCategoryDictSave({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('upmsCategoryDict/save', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 分类字典更新
     */
    upmsCategoryDictUpdate({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('upmsCategoryDict/update/' + params.id, params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 分类字典删除
     */
    upmsCategoryDictRemove({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('upmsCategoryDict/remove', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default UpmsCategoryDictService
